<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-31 17:46:49
 * @LastEditTime: 2019-11-28 15:58:02
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../../css/local.css" />
    <link rel="stylesheet" type="text/css" href="../../font/iconfont.css" />
    <link rel="stylesheet" href="../../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/layer/layer.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script src="../../script/elementui/lib/index.js?t=1"></script>
    <script src="../../script/elementui/vue-element-bigdata-table.min.js?t=4"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <script type="text/javascript" src="../../script/JSLINQ.js"></script>
    <script type="text/javascript" src="../../script/ajaxFileUpload.js"></script>
    <style type="text/css">
        body {
            zoom: 0.9;
        }

        .innerBox {
            flex: 1;
            overflow: auto;
        }

        .mainForm {
            /* height: 60%; */
            width: 99%;
            overflow-y: auto;
            display: flex;
            flex-wrap: wrap;
            flex: 1;
        }

        .van-field {
            width: 50%;
        }

        .van-field__label {
            width: auto;
        }

        .subFrame {
            /* width: 100%; */
            height: 50%
        }

        .title {
            width: 25%;
            background-color: #83bff6;
            text-align: center;
            margin: 2px auto 2px 0;
            padding: 4px 1px;
            color: #fff;
            font-size: 17px;
        }

        .van-icon-delete {
            color: red;
        }

        .van-tabs {
            width: 100%;
            height: auto;
        }

        .van-tabs__wrap {
            width: 70vw;
        }

        .van-tabs__nav--card {
            border: 1px solid #83bff6;
        }

        .van-tab--card.van-tab--active {
            background-color: #83bff6;
        }

        .van-tab--card {
            color: #83bff6;
            border-right: #83bff6;
        }

        .van-tab {
            padding: 0;
            margin: 0;
        }

        .van-tabs__content {
            width: 100%;
        }

        .van-tabs__nav {
            width: 25%;
        }

        .part {
            width: 100%;
            margin-top: 0px;
            padding: 0px 5px 3px 5px;
            box-sizing: border-box;
        }

        .part .pf {
            border-radius: 6px;
            box-shadow: 0px 1px 5px rgb(200, 198, 198);
            background-color: #fff;
            overflow: hidden;
            position: relative;
            margin-top: 10px;
        }

        .van-badge {
            margin: 10px 10px;
            background-color: #1989fa;
            color: #fff;
            display: block;
            width: 22px;
            padding: 3px;
            float: left;
            vertical-align: middle;
        }

        .van-cell,
        .van-field {
            width: 100%;
            padding: 5px 16px !important;
        }

        .van-cell {
            padding: 10px 8px 10px 12px;
        }

        .form .van-cell__title {
            max-width: 100px;
            color: #969799;
        }

        .form .van-cell__value {
            text-align: left;
        }

        .van-field__label {
            width: 100px;
            color: #969799;
        }

        .van-cell::after {
            position: absolute;
            box-sizing: border-box;
            content: ' ';
            pointer-events: none;
            right: 8px;
            bottom: 0;
            left: 12px;
            border-bottom: 1px solid #ebedf0;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }

        .part1 {
            padding: 15px 15px 0 15px;
        }

        .part1 .pf {
            border-radius: 6px;
            box-shadow: 0px 1px 5px rgb(200, 198, 198);
            background-color: #fff;
            overflow: hidden;
        }

        .textarea {
            display: block;
        }

        .label {
            padding: 10px 16px;
        }

        .ap-f {
            border-bottom: 1px solid #f7f7f7;
        }

        .mark {
            padding: 17px 15px;
        }

        .mark1 {
            padding: 17px 5px 17px 15px;
            position: relative;
        }

        .f-sub {
            color: #969799;
            font-size: 13px;
            margin-top: 4px;
        }

        .line {
            position: relative;
            width: 30px;
        }

        .line1 {
            width: 60px;
        }

        .line-sq {
            display: inline-block;
            width: 11px;
            height: 11px;
            border-radius: 6px;
            background: #d6d6d6;
            position: absolute;
            left: 0;
            top: 12px;
        }

        .line-li {
            display: inline-block;
            width: 1px;
            background: #d6d6d6;
            position: absolute;
            left: 5px;
            top: -17px;
            bottom: -17px;
        }

        .line-li1 {
            display: inline-block;
            background: #d6d6d6;
            position: absolute;
            top: 52px;
            left: 35px;
            width: 3px;
            bottom: 10px;
        }

        .pd {
            padding: 16px 0;
        }

        .ap-r {
            text-align: right;
            padding-right: 10px;
            /* margin: -8px 0; */
            padding-top: 10px;
        }

        .ap-d {
            text-align: right;
            padding-right: 10px;
            color: #ccccce;
            font-size: 13px;
            float: right;
            padding-top: 3px;
        }

        .img {
            width: 34px;
            height: 34px;
            line-height: 34px;
            text-align: center;
            font-size: 12px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            margin: 0 auto;
            position: relative;
            user-select: none;
        }

        .img1 {
            width: 44px;
            height: 44px;
            line-height: 44px;
            text-align: center;
            font-size: 13px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            position: relative;
            user-select: none;
        }

        .dis-ib {
            display: inline-block;
            vertical-align: middle;
            text-align: center;
            min-width: 40px;
        }

        .dis2-ib {
            display: inline-block;
            vertical-align: middle;
            padding-bottom: 3px;
            text-align: center;
        }

        .dis3-ib {
            display: inline-block;
            margin: 0 6px;
            color: #969799;
            vertical-align: top;
            padding-top: 7px;
            text-align: center;
        }

        .ap-n {
            padding-top: 2px;
            font-size: 13px;
            color: #969799;
            text-align: center;
        }

        .bottom {
            padding: 8px 15px;
        }

        .part-white {
            padding: 15px;
            background-color: #fff;
            position: relative;
        }

        .title {
            line-height: 40px;
            font-size: 18px;
        }

        .title-sub {
            color: #aaacac;
            font-size: 13px;
        }

        .title-read {
            color: #3396fb;
            font-size: 13px;

        }

        .title-unread {
            color: #788a8a;
            font-size: 13px;
        }

        .ap-res {
            color: #a3a3a3;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-res1 {
            color: #c31616;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-img {
            position: absolute;
            right: 20px;
            bottom: -38px;
            width: 88px;
            opacity: 0.4;
        }

        .form-row {
            padding: 4px 16px;
        }

        .form-label {
            color: #808991;
            font-size: 13px;
            user-select: none;
        }

        .form-content {
            padding-top: 5px;
        }

        .npd {
            padding-top: 0;
            overflow-x: auto;
        }

        .pl {
            color: #969799;
            font-size: 16px;
            margin: 6px 2px 18px 0;
            min-height: 25px;
            border-bottom: 1px solid #ebedf0;
        }

        .sf {
            width: 16px;
            background: #fff;
            padding: 2px;
            border-radius: 8px;
            position: absolute;
            right: -5px;
            bottom: -2px;
        }

        .select {
            color: #3396fb;
            float: right;
            font-size: 13px;
            padding-top: 3px;
            vertical-align: middle;
        }

        .select a {
            vertical-align: middle;
        }

        .select img {
            width: 16px;
            vertical-align: middle;
        }

        .hq {
            padding: 10px 10px 0 0;
        }

        .wh {

            white-space: nowrap;
            overflow-x: auto;
            padding-right: 10px;
        }

        .plpd {
            padding-bottom: 5px;
        }

        .pictitle {
            line-height: 24px;
            color: #646566;
            user-select: none;
        }

        .piccontent {
            padding-top: 10px;
            overflow: hidden;
        }

        .van-uploader__preview {
            margin-right: 15px;
        }

        .no {
            text-align: center;
            color: #808991;
            font-size: 14px;
        }

        .li1 {
            top: 15px;
        }

        .li2 {
            bottom: 24px;
        }

        .da-c {
            color: #c31616;
        }

        .danger .van-field__control {
            color: #c31616;
        }

        .danger .van-field__label {
            color: #808991;
        }

        .ac-1 {
            color: #03b553;
        }

        .ac-2 {
            color: #c31616;
        }

        .checkbox {
            padding: 25px 5px 10px 10px;
        }

        .jl-remark {
            padding: 5px 0;
            color: #3396fb;
        }

        .memo-l {
            border-bottom: 1px solid rgb(235, 237, 240);
            padding: 4px 0;
        }

        .memo-l:last-child {
            border-bottom: 0;
        }

        .approvePop {
            box-sizing: border-box;
            padding: 20px 30px;
        }

        .approvePop .approveBtns {
            position: absolute;
            bottom: 0;
            width: 100%;
            box-sizing: border-box;
            display: flex;
        }

        .approvePop .approveBtns .van-button {
            width: 60%;
            margin: auto;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" id="box">
            <van-nav-bar id="van-nav-bar" :title="titleName" left-arrow @click-left="onClickLeft">
                <div slot="right">
                    <span slot="right" @click="openScan" v-if="!isPDA">
                        <img src="../../image/scan.png" />
                    </span>
                    <span slot="right" @click="openPrint" v-if="isPDA && printConfig">
                        <img src="../../image/print.png" />
                    </span>
                </div>
            </van-nav-bar>

            <div class="innerBox">
                <div class="mainForm">
                    <van-field v-model="formData.BillNO" label="单据编号" placeholder="单据编号" readonly></van-field>
                    <van-field v-model="formData.BillDate" label="单据日期" placeholder="请输入单据日期" readonly>
                    </van-field>
                    <van-field v-model="formData.ProductCode" label="品号" placeholder="请输入品号" readonly></van-field>
                    <van-field v-model="formData.ProductName" label="品名" placeholder="请输入品名" readonly></van-field>
                    <van-field v-model="formData.ProcuctSpec" label="规格" placeholder="请输入规格" readonly></van-field>
                    <van-field v-model="formData.CPTH" label="图号" placeholder="请输入图号" readonly></van-field>
                    <van-field v-model="formData.DispatchDate" label="生产日期" placeholder="请输入生产日期" class='label1'
                        readonly required @click="handlerShowDate">
                    </van-field>
                    <van-field v-model="formData.ProcedureName" label="工序" placeholder="请输入工序" readonly is-link
                        @click="handlerProcedure"></van-field>
                    <van-field v-model="formData.WorkShopName" label="生产车间" placeholder="请输入生产车间" readonly>
                    </van-field>
                    <van-field v-model="formData.LabourCost" label="原单价" placeholder="请输入原单价" readonly></van-field>
                    <van-field v-model="formData.WCQty" label="已报工数量" placeholder="请输入已报工数量" readonly></van-field>
                    <van-field v-model="formData.FQty" label="计划数量" placeholder="请输入计划数量" readonly></van-field>
                    <van-field v-model="formData.UserName" label="发起人" placeholder="请输入发起人" class='label1' readonly
                        required>
                    </van-field>
                    <van-field v-model="formData.EmplName" label="生产人员" placeholder="请输入生产人员" class='label1' readonly
                        required is-link @click="openSelectPicker('人员')"></van-field>
                    <van-field v-model="formData.FDailyQtt" label="工作数量" placeholder="请输入工作数量" class='label1' required
                        :disabled="formDisabled" @input="handlerBCMoney">
                    </van-field>
                    <van-field v-model="formData.XSGJ" label="补偿单价" placeholder="请输入补偿单价" :disabled="formDisabled"
                        @input="handlerBCMoney">
                    </van-field>
                    <van-field v-model="formData.BCGS" label="花费工时" placeholder="请输入花费工时" :disabled="formDisabled">
                    </van-field>
                    <van-field v-model="formData.BCMoney" label="补偿金额" placeholder="请输入补偿金额" readonly></van-field>
                    <van-field v-model="formData.WorkContent" label="工作内容描述" placeholder="请输入工作内容描述"
                        :disabled="formDisabled"></van-field>
                    <van-field v-model="formData.ReviewStatus" label="审批状态" placeholder="请输入审核状态" readonly></van-field>
                </div>

                <div class="subFrame" v-if="approvalList.length">
                    <div class="part1" v-for="approvalRow in approvalList">
                        <div class="pf">
                            <div class="label">流程</div>
                            <div class="pd">
                                <div>
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1"><span>{{formData.UserName}}</span><img
                                                                class="sf" src="../../image/success.png" /></div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div>
                                                    <span>发起审批</span>
                                                    <span
                                                        class="ap-d">{{formData.BillDate.split('.')[0].replace(/T/g,'')}}</span>
                                                </div>
                                                <div class="f-sub">{{formData.UserName}}</div>
                                            </div>
                                            <div class="pl"></div>
                                        </div>
                                    </div>
                                </div>
                                <div v-for="(row,index) in approvalRow.approvalNodeList">
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span
                                                                v-if="row.node.length == 1 && row.node[0].CurrentApprovalIDs.length == 1 && row.type == 0">{{row.node[0].CurrentApprovalIDs[0]}}</span>
                                                            <van-icon v-else-if="row.type == 1" name="volume-o"
                                                                size="28px" style="padding-top: 7px;">
                                                            </van-icon>
                                                            <van-icon v-else name="friends-o" size="28px"
                                                                style="padding-top: 7px;"></van-icon>
                                                            <img class="sf"
                                                                v-if="approvalRow.level == row.index - 2 && row.type == 1 && row.node[0].Approve != 0"
                                                                src="../../image/success.png" />
                                                            <img class="sf" v-if="approvalRow.level >= row.index - 1"
                                                                :src="getApprovalTagImg(row)" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div class="hq" v-if="row.showMore">
                                                    <!-- 或签 -->
                                                    <div class="wh"
                                                        v-if="row.node.length == 1 && row.node[0].CurrentApprovalIDs.length > 1">
                                                        <div class="dis2-ib"
                                                            v-for="(item,itemIndex) in row.node[0].CurrentApprovalIDs">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item)}}</span>
                                                                    <img class="sf"
                                                                        v-if="item == row.node[0].Approver && approvalRow.level >= row.index - 1 && row.node[0].Approve != 0"
                                                                        :src="row.node[0].Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node[0].CurrentApprovalIDs.length - 1 && row.type == 0">
                                                                /</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>

                                                    </div>
                                                    <!-- 会签 -->
                                                    <div class="wh" v-if="row.node.length > 1 && checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item.CurrentApprovalIDs[0])}}</span>
                                                                    <img class="sf"
                                                                        v-if="item.Approver && item.Approver == item.CurrentApprovalIDs[0] && approvalRow.level >= row.index - 1 && item.Approve != 0"
                                                                        :src="item.Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item.CurrentApprovalIDs[0]}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1 && row.type == 0">
                                                                +</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>
                                                    </div>
                                                    <!-- 多人审核 -->
                                                    <div class="wh" v-if="row.node.length > 1 && !checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis2-ib"
                                                                v-for="(detail,detailIndex) in item.CurrentApprovalIDs">
                                                                <div class="dis-ib">
                                                                    <div class="img">
                                                                        <span>{{cutStr(detail)}}</span>
                                                                    </div>
                                                                    <div class="ap-n">{{detail}}
                                                                    </div>
                                                                </div>
                                                                <div class="dis3-ib"
                                                                    v-if="itemIndex != row.node.length - 1">/</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="pl">
                                                    <div class="plpd" v-for="item in row.node">
                                                        <div>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">{{item.Approver}}:</span>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">"{{item.ApprovalContent}}"</span>
                                                            <div class="ap-d" v-if='item.ApprovalContent'>
                                                                  {{item.ApproveTime}}
                                                            </div>
                                                        </div>

                                                        <div class="piccontent" v-if="item.Imgs">
                                                            <div class="van-uploader">
                                                                <div class="van-uploader__wrapper">
                                                                    <div class="van-uploader__preview"
                                                                        v-for="(imgItem,imgItemIndex) in (item.Imgs?item.Imgs.split(','):[])">
                                                                        <div class="van-image van-uploader__preview-image"
                                                                            style="overflow: hidden; border-radius: 4px;width:60px;height:60px;"
                                                                            @click="previewItemImage(item.Imgs,imgItemIndex,3)">

                                                                            <img :src="serverIP + imgItem"
                                                                                class="van-image__img"
                                                                                style="object-fit: cover;" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="flex-box f-r" v-if="index == approvalRow.approvalNodeList.length - 1">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span>备注</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bottomSubmit"
                    style="position: fixed;bottom: 0px;z-index: 1;width: 100%;padding: 5px 10px;right:0px">
                    <div style="float:right;width:20%;" v-if="whetherShowBtn">
                        <van-button v-if="!btnShow" round block type="info" native-type="submit" @click="saveRow">提交
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="approveFalg">
                        <van-button round block type="info" native-type="submit" @click="submit(0)">重新发起审批</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(2)">拒绝</van-button>
                    </div>
                    <div style="float:right;width:30%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(1)">输入审核意见/确认同意
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">>
                        <van-button round block type="info" native-type="submit" @click="submit(3)">退回</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="dialogVisible = true">转交
                        </van-button>
                    </div>
                </div>
            </div>
            <el-dialog title="转交" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
                <!-- <span>这是一段信息</span> -->
                <el-select v-model="TransmittedUserID" filterable placeholder="请选择">
                    <el-option v-for="item in options" :key="item.userid_num" :label="item.user_name"
                        :value="item.userid_num">
                    </el-option>
                </el-select>

                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="Transmitted">确 定</el-button>
                </span>
            </el-dialog>

            <van-popup class="approvePop" v-model="approveShow" closeable close-icon="close" position="bottom"
                :style="{ height: '40%' }">
                <van-field v-model="approveData.approveData" label="审批意见" placeholder="请输入审批意见"></van-field>
                <div class="approveBtns">
                    <van-button type="info" @click="approveSave">保存</van-button>
                </div>
            </van-popup>

            <van-action-sheet v-model="classShow" :actions="classActions" @select="onSelectClass">
            </van-action-sheet>

            <van-action-sheet v-model="procedureShow" :actions="procedureActions" @select="onSelectProcedure">
            </van-action-sheet>

            <van-popup position="bottom" v-model="showDate">
                <van-datetime-picker v-model="currentDate" type="date" title="选择生产日期" @confirm="confirmDate"
                    @cancel="showDate = false"></van-datetime-picker>
            </van-popup>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {

        var FNScanner = api.require('FNScanner');
        var scanTC80 = api.require('scanTC80');
        var escPrinter = api.require('escPrinter');
        var scanS60A = api.require('ScanS60A');
        var scanDT40 = api.require('scanDT40');
        var FNPhotograph = api.require('FNPhotograph');
        var photoBrowser = api.require('photoBrowser');
        var docReader = api.require('docReader');

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            console.log('ret', JSON.stringify(ret))
            if (ret.value.type == '大工单子表人员') {
                vm.formData.EmplName = ret.value.row.EmplName
                vm.formData.EmplID = ret.value.row.userid_num
                vm.formData.ClassID = ret.value.row.ClassID
            }
        })

        vm = new Vue({
            el: '#app',
            data: {
                options: [],
                TransmittedUserID: '',
                dialogVisible: false,
                titleName: api.pageParam.titleName,
                isPDA: api.deviceModel.indexOf('PDA') > -1 ? true : false,
                printConfig: '',
                formData: {
                    Ck_ReviewID: '',
                    CompensationSheetID: '',
                    CompensationSheetDeID: '',
                    DispatchingID: '',
                    BB: '',
                    ID: '',
                    PMCProcessRouteID: '',
                    QrCode: '',
                    BillNO: '',
                    BillDate: '',
                    WorkShopName: '',
                    WorkShopCode: '',
                    ProductCode: '',
                    ProductName: '',
                    ProcuctSpec: '',
                    CPTH: '',
                    DispatchDate: '',
                    class: '',
                    ProcedureName: '',
                    ProcedureID: '',
                    LabourCost: '',
                    WCQty: '',
                    FQty: '',
                    UserName: '',
                    FQR: '',
                    EmplName: '',
                    EmplID: '',
                    ClassID: '',
                    FDailyQtt: '',
                    XSGJ: '',
                    BCGS: '',
                    BCMoney: '',
                    ReviewStatus: '',
                    WorkContent: '',
                    ReviewStacommenttus: '',
                },
                serverIP: APP.serverIP(),
                finalResult: '',
                approvalList: [],
                status: 0,
                approvalID: '',
                approveShow: false,
                approveData: {
                    content: ''
                },
                approveFalg: false,
                userData: APP.getUserInfo(),
                btnShow: false,
                whetherShowBtn: true,
                classShow: false,
                classActions: [
                    {
                        name: '白班',
                        value: 1
                    },
                    {
                        name: '夜班',
                        value: 0
                    }
                ],
                procedureShow: false,
                procedureActions: [],
                showDate: false,
                currentDate: new Date(),
                formDisabled: false
            },
            created: function () {
                var that = this
                that.zhuanjiao()

                if (api.pageParam.historyData) {
                    that.whetherShowBtn = false
                    console.log('historyData', JSON.stringify(api.pageParam.historyData))
                    that.formData.CompensationSheetID = api.pageParam.historyData.CompensationSheetID
                    that.getInitHistoryData()  //获取明细数据
                    APP.ajax('selectPSIDByBCDID', { CompensationSheetID: that.formData.CompensationSheetID }, function (res) { //获取审批数据
                        console.log('res', JSON.stringify(res))
                        if (res.ds.length) {  //获取评审流程
                            that.formData.Ck_ReviewID = res.ds[0].Ck_BCDReviewID
                            that.getHistoryData()
                            that.checkIsShowButton()
                        }
                    })
                } else {
                    that.whetherShowBtn = true
                    that.formData.BillNO = '自动生成'
                    that.formData.class = '白班'
                    that.formData.FQR = APP.getUserInfo().UserID
                    that.formData.UserName = APP.getUserInfo().UserName
                    that.formData.ReviewStatus = '未审批'
                    that.formDisabled = false
                }
            },
            mounted() {
                var navBar = document.getElementById('van-nav-bar')
                navBar.style.paddingTop = api.safeArea.top + 'px'

                let height = document.body.clientHeight
                window.onresize = () => { // 在页面大小发生变化时调用
                    // 把获取到的高度赋值给根div
                    document.getElementById('app').style.height = height + 'px'
                }
            },
            methods: {
                handleClose() {
                    var that = this
                    that.dialogVisible = false
                },
                Transmitted() {
                    var that = this
                    var obj = {
                        TableName: 'Pr_CompensationSheet',
                        APFlowID: 2,
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        ReviewType: 8,
                        ApprovalID: that.formData.CompensationSheetID,
                        UserCode: that.TransmittedUserID
                    }

                    console.log('BhgQjzjpsbgApproveList', JSON.stringify(obj))
                    APP.ajax('BhgQjzjpsbgApprove', obj, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            that.dialogVisible = false
                            api.toast({
                                msg: res.ds[0].msg
                            })
                            that.addSP_Message(4)
                        }

                    })
                    // that.dialogVisible = false
                },
                zhuanjiao(val) {
                    var that = this
                    APP.ajax('PC_PCRYXL', {}, function (res) {
                        // console.log('PC_PCRYXL',JSON.stringify(res))
                        that.options = res.ds
                    })
                },
                addSP_Message(val) {
                    var that = this
                    var obj1 = {
                        SourceTable: 'Pr_CompensationSheet',
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        SourceID: that.formData.CompensationSheetID,
                        UserCode: that.TransmittedUserID,
                        Status: val,
                        UserID: APP.getUserInfo().UserID,
                    }
                    APP.ajax('SP_Message', obj1, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            api.toast({
                                msg: res.ds[0].msg
                            })
                        }
                    })

                },

                onClickLeft() {
                    api.closeWin();
                },

                handlerShowDate() {
                    var that = this
                    if (that.formData.ReviewStatus == '未审批') {
                        that.showDate = true
                    }
                },

                confirmDate(val) {
                    var that = this
                    that.formData.DispatchDate = APP.getFormatDateTime(val).split(' ')[0]
                    that.showDate = false
                },

                onSelectClass(val) {
                    var that = this
                    that.formData.class = val.name
                    that.classShow = false
                },

                handlerProcedure() {
                    var that = this
                    if (!that.formData.QrCode) {
                        vm.$toast('请先扫描流转码！')
                        return false
                    }
                    var obj = {
                        EmplID: APP.getUserInfo().UserID,
                        QrCode: that.formData.QrCode
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('get_pdu', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        res.ds.map((item) => {
                            item.name = item.ProcedureName
                        })
                        that.procedureActions = res.ds
                        that.procedureShow = true
                    })
                },

                onSelectProcedure(val) {
                    var that = this
                    that.formData.ProcedureName = val.ProcedureName
                    that.formData.PMCProcessRouteID = that.formData.ProcedureID = val.ProcedureID
                    var obj = {
                        PMCProcessRouteID: that.formData.ProcedureID,
                        ProductCode: that.formData.ProductCode,
                        QrCode: that.formData.QrCode
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('getWCSLbyBCDDGX', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.formData.FQty = res.ds[0].FQty
                        that.formData.WorkShopName = res.ds[0].workshopName
                        that.formData.WorkShopCode = res.ds[0].WorkShopCode
                        that.formData.FQty = res.ds[0].FQty
                        that.formData.LabourCost = res.ds[0].LabourCost
                        that.formData.WCQty = res.ds[0].WCQty
                    })
                    that.procedureShow = false
                },

                handlerBCMoney() {
                    var that = this
                    if (that.formData.FDailyQtt && that.formData.XSGJ) {
                        that.formData.BCMoney = Number(that.formData.FDailyQtt) * Number(that.formData.XSGJ)
                    }
                },

                openSelectPicker() {
                    var that = this
                    if (that.formData.ReviewStatus == '未审批') {
                        api.openWin({
                            name: 'treeMultipleChoose',
                            url: '../tool/treeMultipleChoose.html',
                            reload: true,
                            slidBackEnabled: false,
                            pageParam: {
                                cmd: 'APP_DG_RYXL'
                            }
                        })
                    }
                },

                filterPersonList: function (str, value) {
                    var that = this;
                    var row = null;
                    for (var i in that.personList) {
                        if (that.personList[i][str] == value) {
                            row = that.personList[i];
                            break;
                        }
                    }
                    return row;
                },

                getApprovalTagImg: function (row) {
                    var that = this;
                    if (row.node.length == 1) {
                        if (row.node[0].Approve == 0) {
                            return '../../image/doing.png';
                        } else if (row.node[0].Approve == 1) {
                            return '../../image/success.png';
                        } else if (row.node[0].Approve == 2) {
                            return '../../image/fail.png';
                        }
                    } else {

                        var imgstr = '';
                        var z = 0;
                        for (var i in row.node) {
                            if (row.node[i].Approve == 1) {
                                z++;
                            }
                            if (row.node[i].Approve == 2) {
                                imgstr = '../../image/fail.png';
                                break;
                            }
                        }
                        if (imgstr) {
                            return imgstr;
                        } else {
                            if (z == 0) {
                                imgstr = '../../image/doing.png'
                            } else {
                                if (row.node.length == z) {
                                    imgstr = '../../image/success.png'
                                } else {
                                    imgstr = '../../image/doing.png';
                                }
                            }

                        }
                        return imgstr;
                    }
                },

                checkIsShowButton: function () {
                    var that = this;
                    var obj = {
                        P_TableName: 'Pr_CompensationSheet',
                        P_PKValue: that.formData.CompensationSheetID
                    }
                    console.log('Btnobj', JSON.stringify(obj))
                    APP.ajax('WhetherItCanBeApproved', obj, function (res) {
                        console.log('Btnres', JSON.stringify(res))
                        that.btnShow = res.ds[0].ISSP;
                    })
                },

                getHistoryData(apstatus) {
                    var that = this
                    var obj = {
                        Ck_ReviewID: that.formData.Ck_ReviewID
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('getCkBCDReviewByID', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.status = res.ds[0].Status
                        that.approvalID = res.ds[0].APFlowID
                        var obj2 = {
                            P_PKValue: that.formData.CompensationSheetID,
                            P_TableName: 'Pr_CompensationSheet'
                        }
                        console.log('obj2', JSON.stringify(obj2))
                        APP.ajax('Select_FlowLog1', obj2, function (res) {
                            console.log('res', JSON.stringify(res))
                            console.log('APP.getUserInfo().UserName', JSON.stringify(APP.getUserInfo().UserName))
                            console.log('res.ds[0].Creater', JSON.stringify(res.ds[0].Creater))

                            if (APP.getUserInfo().UserName == res.ds[0].Creater) {
                                res.ds.map((item) => {
                                    if (item.Approve == 2) { //显示重新审批按钮
                                        that.approveFalg = true
                                        that.formDisabled = false
                                    }
                                })
                                // console.log('approveFalg', JSON.stringify(that.approveFalg))
                            } else {
                                that.formDisabled = true
                            }


                            var data = [];
                            allCurrentApprovalIDs = [];
                            var allCurrentApprovalIDs2 = [];
                            for (var i in res.ds) {

                                res.ds[i].CurrentApprovalIDs = res.ds[i].CurrentApprovalIDs ? res.ds[i].CurrentApprovalIDs.replace(/^,+/, "").replace(/,+$/, "").split(',') : '';

                                allCurrentApprovalIDs = allCurrentApprovalIDs.concat(res.ds[i].CurrentApprovalIDs);
                                if (res.ds[i].FlowType != 1) {
                                    allCurrentApprovalIDs2 = allCurrentApprovalIDs2.concat(res.ds[i].CurrentApprovalIDs);
                                }
                                for (var c in res.ds[i].CurrentApprovalIDs) {
                                    var row = that.filterPersonList('UserID', res.ds[i].CurrentApprovalIDs[c])
                                    if (row) {
                                        res.ds[i].CurrentApprovalIDs[c] = row.UserName;
                                    }
                                }

                                if (data.indexOf(res.ds[i].AuditID) == -1) {
                                    data.push(res.ds[i].AuditID);
                                }
                            }

                            var approvalList = [];
                            for (var n in data) {
                                var approvalNodeList = [];
                                var level = 0;
                                var finLevel = 0;
                                for (var i in res.ds) {
                                    if (data[n] == res.ds[i].AuditID) {

                                        if (res.ds[i].Approve == 0 && !level) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 1 && i == res.ds.length - 1) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && !finLevel) {
                                            finLevel = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && n == data.length - 1) {
                                            that.finalResult = 2;
                                        }

                                        var x = 0;
                                        for (var j in approvalNodeList) {
                                            if (approvalNodeList[j].index == res.ds[i].ApprovalSort) {
                                                x = 1;
                                                approvalNodeList[j].node.push(res.ds[i]);
                                            }
                                        }
                                        if (!x) {
                                            approvalNodeList.push({
                                                index: res.ds[i].ApprovalSort,
                                                type: res.ds[i].FlowType,
                                                department: res.ds[i].ApprovalName,
                                                node: [res.ds[i]]
                                            })
                                        }
                                    }
                                }
                                approvalList.push({
                                    level: finLevel ? (finLevel - 1) : (level - 1),
                                    approvalNodeList: approvalNodeList
                                })
                            }

                            var p1 = 0;
                            var y = 0;
                            if (that.finalResult == 1) {
                                for (var i in res.ds) {
                                    if (res.ds[i].Approver && res.ds[i].FlowType != 1) {
                                        p1++;
                                        if (res.ds[i].Approver == that.userData.UserName) {
                                            y = 1;

                                        }
                                    }

                                }

                                // console.log('Ck_ReviewID', JSON.stringify(that.formData.Ck_ReviewID))
                            }
                            that.approvalList = approvalList;
                            console.log('approvalList', JSON.stringify(that.approvalList))
                        })
                    })
                },

                getInitHistoryData() {
                    var that = this
                    var obj = {
                        CompensationSheetID: that.formData.CompensationSheetID
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('APP_BCDMX', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        // that.formData.LargeWorkID = res.ds[0].LargeWorkID
                        that.formData.BillNO = res.ds[0].BillNO
                        that.formData.BillDate = res.ds[0].BillDate
                        that.formData.DispatchDate = res.ds[0].ActualDate
                        that.formData.FQR = res.ds[0].FQR
                        that.formData.UserName = res.ds[0].UserName
                        that.formData.ReviewStatus = res.ds[0].ReviewStatus
                        that.formData.WorkShopCode = res.ds[0].WorkShopCode
                        that.formData.WorkShopName = res.ds[0].WorkShopName
                        that.formData.ProductCode = res.ds1[0].ProductCode
                        that.formData.ProductName = res.ds1[0].ProductName
                        that.formData.ProcuctSpec = res.ds1[0].ProductSpec
                        that.formData.CPTH = res.ds1[0].TH
                        that.formData.FQty = res.ds1[0].FQty
                        that.formData.FDailyQtt = res.ds1[0].FDailyQtt
                        that.formData.ProcedureID = res.ds1[0].ProcedureID
                        that.formData.ProcedureName = res.ds1[0].ProcedureName
                        that.formData.EmplID = res.ds1[0].EmplID
                        that.formData.EmplName = res.ds1[0].EmplName
                        that.formData.LabourCost = res.ds1[0].YDJ
                        that.formData.WCQty = res.ds1[0].WCQty
                        that.formData.XSGJ = res.ds1[0].XSGJ
                        that.formData.BCGS = res.ds1[0].BCGS
                        that.formData.BCMoney = res.ds1[0].BCMoney
                        that.formData.WorkContent = res.ds1[0].WorkContent
                        that.formData.ReviewStacommenttus = res.ds1[0].comment
                        that.formData.ClassID = res.ds1[0].ClassID
                        that.formData.CompensationSheetDeID = res.ds1[0].CompensationSheetDeID
                    })
                },
                saveRow() {
                    that = this
                    var obj, cmd
                    if (api.pageParam.historyData) {  //修改
                        obj = {
                            CompensationSheetDeID: that.formData.CompensationSheetDeID,
                            CPTH: that.formData.CPTH,
                            ProductSpec: that.formData.ProcuctSpec,
                            ProductCode: that.formData.ProductCode,
                            ProductName: that.formData.ProductName,
                            CompensationSheetID: that.formData.CompensationSheetID,
                            EmplID: that.formData.EmplID,
                            BCMoney: that.formData.BCMoney,
                            XSGJ: that.formData.XSGJ,
                            WorkContent: that.formData.WorkContent,
                            BCGS: that.formData.BCGS,
                            FQR: that.formData.FQR,
                            YDJ: that.formData.LabourCost,
                            comment: that.formData.ReviewStacommenttus,
                            FDailyQtt: that.formData.FDailyQtt,
                        }
                        cmd = 'APP_BCD_UPDATE'
                    } else {
                        obj = {
                            ProductSpec: that.formData.ProcuctSpec,
                            ProductCode: that.formData.ProductCode,
                            CPTH: that.formData.CPTH,
                            ProductName: that.formData.ProductName,
                            EmplID: that.formData.EmplID,
                            XSGJ: that.formData.XSGJ,
                            FQR: that.formData.FQR,
                            BCMoney: that.formData.BCMoney,
                            WorkContent: that.formData.WorkContent,
                            comment: that.formData.ReviewStacommenttus,
                            BCGS: that.formData.BCGS,
                            ProcedureID: that.formData.ProcedureID,
                            YDJ: that.formData.LabourCost,
                            FQty: that.formData.FQty,
                            WCQty: that.formData.WCQty,
                            FDailyQtt: that.formData.FDailyQtt,
                            DispatchingID: that.formData.DispatchingID,
                            BB: that.formData.BB,
                            ID: that.formData.ID,
                            QrCode: that.formData.QrCode,
                            PMCProcessRouteID: that.formData.PMCProcessRouteID,
                            WorkShopCode: that.formData.WorkShopCode,
                        }
                        cmd = "APP_BCD_ADD"
                    }
                    console.log('obj', JSON.stringify(obj))
                    console.log('cmd', JSON.stringify(cmd))
                    APP.ajax(cmd, obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (cmd == "APP_BCD_ADD") {  //提交接口
                            if (res.ds1[0].status == 200) {
                                that.formData.BillNO = res.ds[0].BillNO3
                                that.formData.CompensationSheetID = res.ds[0].CompensationSheetID
                                var obj1 = {
                                    IsReworkDepart: -1,
                                    P_Timeout: 0,
                                    ClassID: vm.formData.ClassID,
                                    UserID: parseInt(that.formData.FQR),
                                    FRemarks: that.formData.ReviewStacommenttus,
                                    NgCause: that.formData.WorkContent,
                                    CompensationSheetID: that.formData.CompensationSheetID
                                }
                                console.log('obj1', JSON.stringify(obj1))
                                APP.ajax('addBCDReviewApprove', obj1, function (res) {
                                    console.log('res', JSON.stringify(res))
                                    that.formData.Ck_ReviewID = res.ds[0].Ck_ReviewID
                                    var obj2 = {
                                        Ck_ReviewID: that.formData.Ck_ReviewID,
                                        TableName: 'Pr_CompensationSheet',
                                        approveType: 0,
                                        ApprovalID: that.formData.CompensationSheetID,
                                        APFlowID: 2
                                    }
                                    console.log('obj2', JSON.stringify(obj2))
                                    APP.ajax('BCDbgApprove', obj2, function (res) {
                                        console.log('bgApprove', JSON.stringify(res))
                                        if (res.ds[0].status == 0) {
                                            vm.$toast('提交审批成功！');

                                            api.sendEvent({
                                                name: 'refresh'
                                            })
                                            setTimeout(() => {
                                                api.closeWin()
                                            }, 1500)
                                        } else {
                                            vm.$toast(res.ds[0].msg);
                                        }
                                    })
                                })
                            }
                        } else {  //修改接口
                            if (res.ds[0].status == 200) {
                                vm.$toast('修改成功！');

                                api.sendEvent({
                                    name: 'refresh'
                                })
                            } else {
                                vm.$toast('修改失败，请重试！');
                            }
                        }
                    })
                },

                approveSave() {
                    var that = this
                    obj = {
                        Approve: that.approveFlag,
                        TableName: 'Pr_CompensationSheet',
                        KeyID: that.formData.CompensationSheetID,
                        ApprovalContent: that.approveData.approveData,
                        ApprovalID: 2,
                        ApprovalSort: that.approvalList[that.approvalList.length - 1].level + 1,
                        Imgs: '',
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('Ck_ApprovalForm', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].STATUS == 0) {
                            var obj1 = {
                                CompensationSheetID: that.formData.CompensationSheetID,
                                UserID: APP.getUserInfo().UserID,
                                status: that.approveFlag == 1 ? 0 : 1,
                                ReviewType: 8,
                                SourceTable: 'Pr_CompensationSheet'
                            }
                            console.log('obj1', JSON.stringify(obj1))
                            APP.ajax('selectQJPSSPZTByUserID', obj1, function (res) {
                                console.log('res', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    vm.$toast(res.ds[0].msg)
                                    that.addSP_Message(that.approveFlag)
                                    if (that.approvalList[0].approvalNodeList[3].node[0].CurrentApprovalIDs.includes(APP.getUserInfo().UserName) && that.formData.ClassID) {
                                        if (that.approveFlag == 1) {
                                            var obj3 = {
                                                BadReviewID: that.formData.CompensationSheetID,
                                                JYLX: 7
                                            }
                                            APP.ajax('UpdateZHJDTY', obj3, function (res) {
                                                console.log('res', JSON.stringify(res))
                                            })
                                        }
                                    }
                                    api.sendEvent({
                                        name: 'refresh'
                                    })
                                    setTimeout(() => {
                                        api.closeWin()
                                    }, 1500)
                                } else {
                                    vm.$toast(res.ds[0].msg)
                                }
                            })
                        } else {
                            vm.$toast(res.ds[0].msg)
                        }
                    })
                },

                submit(flag) {
                    var that = this
                    that.approveFlag = flag
                    if (flag != 0) {  //同意/拒绝
                        that.approveShow = true
                    } else {  //重新发起审批
                        that.saveRow()
                        var obj = {
                            UserID: APP.getUserInfo().UserID,
                            CompensationSheetID: that.formData.CompensationSheetID,
                            P_Timeout: 0,
                            ClassID: that.formData.ClassID,
                            IsReworkDepart: 1,
                            NgCause: that.formData.WorkContent,
                            Ck_ReviewID: that.formData.Ck_ReviewID,
                        }
                        console.log('obj', JSON.stringify(obj))
                        APP.ajax('updateBCDApproveReview', obj, function (res) {
                            console.log('res', JSON.stringify(res))
                            if (res.ds && res.ds[0].status == 500) {
                                vm.$toast(res.ds[0].msg)
                            } else {
                                vm.$toast('重新发起审批成功！')
                                that.addSP_Message(that.approveFlag)

                                api.sendEvent({
                                    name: 'refresh'
                                })
                                setTimeout(() => {
                                    api.closeWin()
                                }, 1500)
                            }
                        })
                    }
                },

                //摄像头扫描事件
                openScan() {
                    var that = this
                    var resultList = api.hasPermission({
                        list: ['camera']
                    });
                    if (resultList[0].granted) {
                        // 已授权，可以继续下一步操作
                        FNScanner.open({
                            autorotation: true
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.content) {
                                    // alert(ret.content)
                                    that.formData.QrCode = ret.content
                                    APP.ajax('getBCDXX', { QrCode: ret.content }, function (res) {
                                        console.log('res', JSON.stringify(res))
                                        that.formData.BillNO = res.ds[0].BillNO
                                        that.formData.BillDate = APP.getFormatDateTime(new Date()).split(' ')[0]
                                        that.formData.ActualDate = APP.getFormatDateTime(new Date()).split(' ')[0]
                                        that.formData.ProductCode = res.ds[0].ProductCode
                                        that.formData.ProductName = res.ds[0].ProductName
                                        that.formData.ProcuctSpec = res.ds[0].ProcuctSpec
                                        that.formData.CPTH = res.ds[0].CPTH
                                        that.formData.DispatchDate = res.ds[0].DispatchDate.split('T')[0]
                                        that.formData.ProductCode = res.ds[0].ProductCode
                                        that.formData.DispatchingID = res.ds[0].DispatchingID
                                        that.formData.BB = res.ds[0].BB
                                        that.formData.ID = res.ds[0].ID

                                    })
                                    // api.sendEvent({
                                    //     name: 'scanHandler',
                                    //     extra: {
                                    //         scanData: ret.content
                                    //     }
                                    // })
                                }
                            } else {
                                vm.$toast('扫描失败');
                            }
                        });
                    } else {
                        api.confirm({
                            msg: '应用需要您的授权才能访问相机',
                            buttons: ['取消', '去设置']
                        }, function (ret) {
                            if (ret.buttonIndex == 2) {
                                api.requestPermission({
                                    list: ['camera'],
                                }, function (res) {
                                    if (res.list[0].granted) {
                                        // 已授权，可以继续下一步操作
                                        FNScanner.open({
                                            autorotation: true
                                        }, function (ret, err) {
                                            if (ret) {
                                                if (ret.content) {
                                                    api.sendEvent({
                                                        name: 'scanHandler',
                                                        extra: {
                                                            scanData: ret.content
                                                        }
                                                    })
                                                }
                                            } else {
                                                vm.$toast('扫描失败');
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }


                    // var hwScanner = api.require('hwScanner');
                    // hwScanner.defaultScanner({
                    //     formatType: 'ALL'
                    // }, function (ret) {
                    //     if (ret.status) {
                    //         api.sendEvent({
                    //             name: 'scanHandler',
                    //             extra: {
                    //                 scanData: ret.result
                    //             }
                    //         })
                    //     }
                    //     else {
                    //         vm.$toast('扫描失败');
                    //     }
                    // });
                },

                //打开打印
                openPrint() {
                    if (vm.printConfig) {
                        var script = vm.printConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
            }
        })
    };
</script>

</html>